﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Private.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content2" ContentPlaceHolderID="TitleHolder" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadHolder" runat="server">
    <% 
        WebHoiChoMuaBan.Models.Member member = (WebHoiChoMuaBan.Models.Member)ViewData["Member"];
    %>
    <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
    <script type="text/javascript">

        var map = null;
        var geocoder = null;

        function initialize() {
            var latlng = new google.maps.LatLng(-34.397, 150.644);
            var myOptions = {
                zoom: 8,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
        }

        function showAddress(address) {
            var geocoder = new google.maps.Geocoder();
            geocoder.geocode({ 'address': address }, function (results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    map.setCenter(results[0].geometry.location);
                    map.setZoom(15);
                    var marker = new google.maps.Marker({
                        map: map,
                        position: results[0].geometry.location
                    });
                } else {
                    alert("Geocode was not successful for the following reason: " + status);
                }
            });
        }

        $(document).ready(function () {
            initialize();
            showAddress('<%=(member.MemAddress == null) ? "Quận 1, tphcm" : member.MemAddress %>');
        })

        function UpdateMap() {
            if ($("#address").val() != "") {
                var _address = $("#address").val() + ", " + $("#ddlProvince :selected").text();
                alert(_address);
                showAddress(_address);
            }
        }
    </script>

      <script type="text/javascript">
          var map;
          function initialize(name, image) {
              var myLatlng = new google.maps.LatLng(10.790141, 106.633301);
              var myOptions = {
                  zoom: 16,
                  center: myLatlng,
                  mapTypeId: google.maps.MapTypeId.ROADMAP
              };
              var des1 = document.getElementById("memAddLat").innerText;
              var des2 = document.getElementById("memAddLong").innerText;
              var des = new google.maps.LatLng(des1, des2);
              map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
              if (navigator.geolocation) {
                  navigator.geolocation.getCurrentPosition(function (position) {
                      var pos = new google.maps.LatLng(position.coords.latitude,
            position.coords.longitude);
                      var infowindow = new google.maps.InfoWindow({
                          map: map,
                          position: des,
                          content: "<b style='color:#00F'>" + name + "</b> <br/>" + "<img src='/../Content/Images/Upload/" + image + "' height='70' width='50' />"
                      });
                      map.setCenter(des);
                      handleNoGeolocation(true);
                  });
              }
              else {
                  handleNoGeolocation(false);
              }
          }

          function handleNoGeolocation(errorFlag) {
              if (errorFlag) {
                  var content = 'Quá trình tìm kiếm địa điểm của bạn không thể thực hiện.';
              }
              else {
                  var content = 'Trình duyệt của bạn không hỗ trợ ';
              }
              var infowindow = new google.maps.InfoWindow(options);
              map.setCenter(options.position);
          }
    </script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentHolder" runat="server">
    <% 
        WebHoiChoMuaBan.Models.Member member = (WebHoiChoMuaBan.Models.Member)ViewData["Member"];
    %>
    <form action="<%= Url.Action("UpdateProfile","Profile") %>" method="post" enctype="multipart/form-data">
    <div class="private_share_post_top">
        <div class="private_sharepost_menu">
            <ul>
                <li><a href="#" class="menu_select">Sửa trang cá nhân</a></li>
            </ul>
        </div>
    </div>
    <div class="private_comment_top">
        <table width="100%" border="0">
            <% if (Session["MemId"] != null && int.Parse(Session["MemId"] + "") == member.MemId)
               {  %>
            <tr>
                <td width="16%" colspan="2" align="right" valign="middle" class="private_font_bold">
                    Banner
                </td>
                <td width="84%">
                    <input type="file" name="banner" id="banner" />
                    <img alt="" src="<%=WebHoiChoMuaBan.Controllers.Global.Config.IMAGE_LOCATION + member.MemBanner %>"
                        width="100%" height="100px" />
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right" valign="middle" class="private_font_bold">
                    Hình nền
                </td>
                <td>
                    <input type="file" name="background" id="background" />
                    <img alt="" src="<%=WebHoiChoMuaBan.Controllers.Global.Config.IMAGE_LOCATION + member.MemBgImg %>"
                        width="100%" height="100px" />
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right" valign="middle" class="private_font_bold">
                    Avatar
                </td>
                <td>
                    <input type="file" name="avatar" id="avatar" /><br />
                    <img alt="" src="<%=WebHoiChoMuaBan.Controllers.Global.Config.IMAGE_LOCATION + member.MemAvatar %>"
                        width="200px" height="200px" />
                </td>
            </tr>
            <%} %>
            <tr>
                <td colspan="2" align="right" valign="middle" class="private_font_bold">
                    Họ tên
                </td>
                <td>
                    <input type="text" name="fullname" id="fullname" class="input_full" value="<%=member.MemFullname %>" />
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right" valign="middle" class="private_font_bold">
                    Ngày sinh
                </td>
                <td>
                    <input type="text" name="birthday" id="birthday" class="input_full" value="<%=member.MemBirthdate.Value.Date.ToShortDateString() %>" />
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right" valign="middle" class="private_font_bold">
                    Nghề nghiệp
                </td>
                <td>
                    <input type="text" name="job" id="job" class="input_full" value="<%=member.MemJob %>" />
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right" valign="middle" class="private_font_bold">
                    Địa chỉ
                </td>
                <td>
                    <input type="text" name="address" id="address" class="input_60" onchange="UpdateMap()"
                        value="<%=member.MemAddress %>" />
                    <%= Html.DropDownList("ddlProvince", (SelectList)ViewData["Provinces"], new { @class = "input_40", @onchange = "UpdateMap()" })%>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right" valign="middle" class="private_font_bold">
                    Công ty
                </td>
                <td>
                    <input type="text" name="compName" id="compName" class="input_full" value="<%=member.MemCompany %>" />
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right" valign="top" class="private_font_bold">
                    Giới thiệu công ty
                </td>
                <td>
                    <textarea name="introComp" id="introComp" cols="45" rows="5" class="input_full"><%=member.MemCompanyIntro%></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right" valign="top" class="private_font_bold">
                    Giới thiệu bản thân
                </td>
                <td>
                    <textarea name="selfIntro" id="selfIntro" cols="45" rows="5" class="input_full"> <%=member.MemInterval%> </textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right" valign="middle" class="private_font_bold">
                    Website
                </td>
                <td>
                    <input type="text" name="website" id="website" class="input_full" value="<%=member.MemWebSite %>" />
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right" valign="middle" class="private_font_bold">
                    Điện thoại bàn
                </td>
                <td>
                    <input type="text" name="phone" id="phone" class="input_full" value="<%=member.MemHomePhone %>" />
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right" valign="middle" class="private_font_bold">
                    Di động
                </td>
                <td>
                    <input type="text" name="cellphone" id="cellphone" class="input_full" value="<%=member.MemCellPhone %>" />
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right" valign="middle" class="private_font_bold">
                    Fax
                </td>
                <td>
                    <input type="text" name="fax" id="fax" class="input_full" value="<%=member.MemFax %>" />
                </td>
            </tr>
            <tr>
           
                <td colspan="3" align="left">
                     <div id="memAddLat" class="hidden">
            <%=member.MemAddressLatitude%></div>
        <div id="memAddLong" class="hidden">
            <%=member.MemAddressLongitude%></div>
                   <div class="private_write_right" style="margin: 5px;">
                <a href="#bando" onclick="initialize('<%=member.MemFullname %>','<%=member.MemAvatar %>')">
                    <img src="/../Content/Images/viewmap.gif"></a>
            </div>
                   <p class="private_font_bold">
            Xác định vị trí trên bản đồ (Google Map)</p>
        <div id="map_canvas" style="width: 500px; height: 300px">
        </div>
                </td>
            </tr>
            <tr>
                <td align="left">
                </td>
                <td align="right">
                    &nbsp;
                </td>
                <% if (Session["MemId"] != null && int.Parse(Session["MemId"] + "") == member.MemId)
                   {  %>
                <td align="left">
                    <div class="private_margin_topright private_write_right">
                        <input type="submit" class="private_bt_submit_news" value="Hoàn thành" id="input2"
                            style="width: 130px;" />
                    </div>
                </td>
            </tr>
            <%
                } %>
        </table>
    </div>
    </form>
</asp:Content>
